package common.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * Created by dong peng on 2017/11/30.
 *
 * 代理处理器类
 */
public class MyProxyHandler implements InvocationHandler {

    /**
     * 此属性为了方便传入被代理对象
     */
    private Object target;

    public MyProxyHandler(Object obj) {
        this.target = obj;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("代理类处理些准备工作...");
        method.invoke(target,args);
        System.out.println("代理类处理写善后工作...");
        return "代理类";
    }
}
